<%@ page language="java" contentType="text/html; charset=utf-8 " import="java.util.Date,java.text.*,service.community.*,domain.Info,domain.Community,domain.User,java.util.ArrayList"
    pageEncoding="utf-8"%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <base href="<%=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/" %>"/>
    <meta charset="utf-8" />
    	<title></title>
    	</head>
    	<script src="js/mootools.js" type="text/javascript"></script>
        	<script type="text/javascript" src="js/jquery.min.js"></script>
        	<script type="text/javascript" src="js/jquery.imgbox.pack.js"></script>
        <script type="text/javascript">
            var xmlHttp;
             function createXMLHttp(){
                 if(window.XMLHttpRequest){
                    xmlHttp=new XMLHttpRequest();
                  }
                  else{
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                  }
             }
             function StateYes(e){
                  createXMLHttp();
                  xmlHttp.onreadystatechange=checkSateYes;
                  xmlHttp.open("post","InfoStateYes?info_id="+e.value);
                  xmlHttp.send(null);
             }
             function checkSateYes(){
                  if(xmlHttp.readyState==4){
                    	if(xmlHttp.status==200){
                    		if(xmlHttp.responseText!=""&&xmlHttp.responseText!=null){
                    			alert("操作成功");
                    			location.reload();
                    		}
                    		else{
                    	        alert("操作失败");
                    	    }
                    	}
                   }
             }
             function StateNo(e){
                  createXMLHttp();
                  xmlHttp.onreadystatechange=checkSateYes;
                  xmlHttp.open("post","InfoStateNo?info_id="+e.value);
                  xmlHttp.send(null);
             }
             function checkSateNo(){
                  if(xmlHttp.readyState==4){
                    	if(xmlHttp.status==200){
                    		if(xmlHttp.responseText!=""&&xmlHttp.responseText!=null){
                    			alert("操作成功");
                    			location.reload();
                    		}
                    		else{
                    	        alert("操作失败");
                    	    }
                    	}
                   }
             }
        	$(document).ready(function() {


        		$(".example2-1").imgbox({
        			'speedIn'		: 0,
        			'speedOut'		: 0,
        			'alignment'		: 'center',
        			'overlayShow'	: true,
        			'allowMultiple'	: false
        		});
        	});
        	</script>
    	<style type="text/css">
    		body{
    		color: #555;
    		background-color: rgba(0, 0, 0, 0.08);
    		font-size: 80%;
    			}
    		.navigation{
    			position: absolute;
    			height: 100%;
    			width: 20%;
    			top: 0;
    			left: 0;
    			box-shadow: rgba(0, 0, 0, 0.08) 0px 1px 4px 0px;
    			background: white;
    		}
    		.top{
    			position: absolute;
    			top: 0;
    			left: 21%;
    			height: 10%;
    			width: 78%;
    			box-shadow: rgba(0, 0, 0, 0.08) 0px 1px 4px 0px;
    			background: white;
    		}
    		.main{
    			position: absolute;
    			top: 12%;
    			left: 21%;
    			width: 78%;
    			height: 86%;
    			box-shadow: rgba(0, 0, 0, 0.08) 0px 1px 4px 0px;
    			background: white;
    		}
    		.logo{
    			margin: auto;
    			margin-top: 10%;
    			background: url(img/logo.png);
    			width: 60%;
    			margin-bottom:10% ;
    		}
    		.click_box{
    			text-align: center;
    			border-top: black solid 1px;
    			border-bottom: black solid 1px ;
    			background: #199ED8;
    			color: white;
    			padding: 3%;
    			font-size: 160%;
    		}
    		.unclick_box{
    			text-align: center;
    			border-top: black solid 1px;
    			border-bottom: black solid 1px ;
    			padding: 3%;
    			font-size: 160%;
    		}
    		.unclick_box:hover{
    			background: #199ED8;
    			color: white;
    		}
    		.out_login:hover{
    			color: #199ED8;
    		}
    		button{
            		margin:10px;
            		background: #199ED8;
            		font-size: 100%;
            		color: white;
            		width: 100px;
            		height: 30px;
            		border: 0px;
            		border-radius: 5px;
            	}
            	table{
            		position: relative;
            		top: 0;

            		min-height: 25px;
            		line-height: 25px;
            		text-align: center;
            		border-collapse: collapse;
            		top: 0%;
            		left: 5%;
            		width: 90%;
            		height: 75%;
            	}
            	td{
            		height: 6%;
            	}
            	th{
            		background: #199ED8;
            		color: white;
            	}
            	table tr:nth-child(odd){
            		background: #F2F2F2;
            	}
            	input{
            		border: 1px solid #ccc;
            		padding: 7px 0px;
            		border-radius: 3px;
            		padding-left:5px;
            		-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
            		box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
            		-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
            		-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
            		transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s
            	}
            	input:focus{
            		border-color: #66afe9;
            		outline: 0;
            		-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);
            		box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)
            	}
            	.imgbox-img{
            	    position:fixed;
            	    top:10%;
            	    left:20%

            	}
#shadow{
                    				background: #000;
                    				filter: alpha(opacity=50); /* IE的透明度 */
                    				opacity: 0.9; /* 透明度 */
                    				display: none;
                    				position: fixed;
                    				top: 0px;
                    				left: 0px;
                    				width: 100%;
                    				height: 100%;
                    				z-index: 100; /* 此处的图层要大于页面 */
                    				display: none;
                    			}
                    			.box{
                    				border: 1px solid black;
                    				width: 30%;
                    				height: 80%;
                    				position: fixed;
                    				top: 10%;
                    				left: 35%;
                    				opacity: 1;
                    				margin: 0 auto;
                    				text-align: center;
                    				background: white;
                    				border-radius: 5px;
                    				z-index: 101;
                    				box-shadow: rgba(0, 0, 0, 0.08) 0px 1px 4px 0px;
									overflow: auto;
                    			}
								.title{
                    				width: 100%;
                    				background: #F2F2F2;
                    				height: 5%;
                    				border-top-left-radius: 5px;
                    				border-top-right-radius: 5px;
                    				box-shadow: rgba(0, 0, 0, 0.08) 0px 1px 4px 0px;
                    				border-bottom: 0.5px antiquewhite solid;
                    				position:relative;
                    				top:0px;
                    			}
    	</style>
    	<%
                    	User user=new User();
                    	if(session.getAttribute("adminloginflag")==null){
                    	%>
                    	<script type="text/javascript">
                    	    window.location.href="admin/login.jsp";
                    	</script>
                        <% }else{
                        user=(User)session.getAttribute("adminloginflag");
                        if(user.getView_power()==""||user.getView_power()=="null"{
                        %>
                        <script type="text/javascript">
                     	    window.location.href="admin/error/error404.jsp";
                     	</script><% }%>
    	<body onload="messageLoad()">
    		<div class="navigation">
    			<center><img src="image/logo.png" class="logo"  /></center>
    			<% if(user.getUsername().equals("admin")){ %><div class="unclick_box" onclick="userManage()">用户配置</div> <% } %>
    			<% if(user.getCommunity_power()==1 ){%><div class="unclick_box" onclick="Community()">社区配置</div> <% } %>
    			<% if(user.getRoom_power()==1 ){%><div class="unclick_box" onclick="Room()">住房审核</div> <% } %>
    			<% if(user.getView_power()!=null&&!user.getView_power().equals("null") ){%><div class="click_box" onclick="info()">人员信息</div> <% } %>
    		</div>
    		<div class="top">
    			<div style="float: left;margin:2%;font-size: 160%;"><%=new SimpleDateFormat("yyyy-MM-dd E").format(new Date())  %></div>
    			<div style="float: right;margin:2%;font-size: 160%;">
    				<span> <img src="image/u954.svg"/></span>
    				<span style="margin-right: 20px;"><%=user.getUsername() %></span>
    				<span class="out_login" onclick="AdminOutlogin()">退出</span>
    			</div>
    		</div>
    		<div class="main">
            <div style="float: right;margin-right: 5%;margin-top: 3%;">
			<form method="post" action="InfoQuery" >
			<select id="community_id" name="community_id" style="width:100px;height:30px">
            					    <option value="0">全部</option>
            						<%  CommunityService communityService =new CommunityServiceImpl() ;
                                    								    ArrayList<Community> li = communityService.queryCommunity(user.getView_power());
                                    								    for(int j=0;j<li.size();j++){
                                    								    if(request.getAttribute("community_id")!=null){
                                    								        int num = Integer.parseInt(request.getAttribute("community_id").toString());
                                    								        if(num==li.get(j).getCommunity_id()){
                                    								%>
                                    <option selected="selected" value="<%=li.get(j).getCommunity_id() %>" ><%=li.get(j).getCommunity_name() %></option><%}else{ %>
                                    <option value="<%=li.get(j).getCommunity_id() %>" ><%=li.get(j).getCommunity_name() %></option> <% }}else{ %>
                                    <option value="<%=li.get(j).getCommunity_id() %>" ><%=li.get(j).getCommunity_name() %></option> <% }}%>
            						</select>
            <% if(request.getAttribute("query")!=null){ %>
            <input type="text" name="query" id="query" placeholder="查询关键字" value="<%=request.getAttribute("query") %>" /><% }else{ %>
			<input type="text" name="query" id="query" placeholder="查询关键字" /><% } %>
			<button type="submit">查询</button>
			</form>
		    </div>
		<table border="1">
			<tr>
			<th width="15%">姓名</th>
			<th width="10%">性别</th>
			<th width="15%">所属社区</th>
			<th width="15%">单元楼栋</th>
			<th width="25%">身份证</th>
			<th width="10%">状态</th>
			<th width="10%">操作</th>

			</tr>
			<% for(int i=0;i<15;i++){ %>
			<tr>
			<% ArrayList<Info> list=(ArrayList)request.getAttribute("list");
			   if(i<list.size()){
			%>
			<td><%=list.get(i).getName() %></td>
			<td><%=list.get(i).getSex() %></td>
			<td><%=list.get(i).getCommunity_name() %></td>
			<td><%=list.get(i).getHousernum() %></td>
			<td><%=list.get(i).getIdcard() %></td>

			<td><% if(list.get(i).getState()==0){ %><span style="color:#555555">待审核</span><% }else if(list.get(i).getState()==1){ %>
			<span style="color:green;">已审核</span><% }else if(list.get(i).getState()==2){ %><span style="color:red;">未通过</span><% }%>
			</td>
			<td style="font-size:80%;">
			<% if(user.getVerify_power()==1){ %>
				<a  onclick="show(<%=list.get(i).getInfo_id() %>,'<%=list.get(i).getName() %>','<%=list.get(i).getSex() %>','<%=list.get(i).getPhone() %>','<%=list.get(i).getHousernum() %>','<%=list.get(i).getCarid() %>','<%=list.get(i).getIdcard() %>','<%=list.get(i).getIdentity_img1() %>','<%=list.get(i).getIdentity_img2() %>','<%=list.get(i).getPhoto_img() %>',<%=list.get(i).getState() %>)" >详情</a>
                <% }else{ %>无相关权限<% }%>
			</td>
			</tr><%} else{%>
			<td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><%}}%>
		</table>
		<% if(request.getAttribute("query")==null &&request.getAttribute("community_id")==null){ %>
		<div style="float: right;margin-right: 5%;margin-top: 1%;">
			<c:choose>
						<c:when test="${page.hasPrePage}">
							<a href="Info?method=list&currentPage=1">首页</a> |
					<a href="Info?method=list&currentPage=${page.currentPage -1 }">上一页</a>
						</c:when>
						<c:otherwise>

						</c:otherwise>
					</c:choose>
				   当前为第${page.currentPage}页,共${page.totalPage}页
			<c:choose>
						<c:when test="${page.hasNextPage}">
							<a href="Info?method=list&currentPage=${page.currentPage + 1 }">下一页</a> |
					<a href="Info?method=list&currentPage=${page.totalPage }">尾页</a>
						</c:when>
						<c:otherwise>

						</c:otherwise>
					</c:choose>
		</div>
			<% }if(request.getAttribute("query")!=null||request.getAttribute("community_id")!=null){ %>
			<div style="float: right;margin-right: 5%;margin-top: 1%;">
            			<c:choose>
            						<c:when test="${page.hasPrePage}">
            							<a href="RoomQuery?method=list&currentPage=1&query=<%=request.getAttribute("query") %>&community_id=<%=request.getAttribute("community_id") %>">首页</a> |
            					<a href="InfoQuery?method=list&currentPage=${page.currentPage -1 }&query=<%=request.getAttribute("query") %>&community_id=<%=request.getAttribute("community_id") %>">上一页</a>
            						</c:when>
            						<c:otherwise>

            						</c:otherwise>
            					</c:choose>
            				   当前为第${page.currentPage}页,共${page.totalPage}页
            			<c:choose>
            						<c:when test="${page.hasNextPage}">
            							<a href="RoomQuery?method=list&currentPage=${page.currentPage + 1 }&query=<%=request.getAttribute("query") %>&community_id=<%=request.getAttribute("community_id") %>">下一页</a> |
            					<a href="InfoQuery?method=list&currentPage=${page.totalPage }&query=<%=request.getAttribute("query") %>&community_id=<%=request.getAttribute("community_id") %>">尾页</a>
            						</c:when>
            						<c:otherwise>

            						</c:otherwise>
            					</c:choose>
            		</div><% } %>
    		</div>
    		<div id="shadow">
            				<div class="box" id="creatuserbox">
            					<div class="title">
            						<span style="margin:5px;float: left;font-weight: 600;">详细信息</span><span style="float: right;margin: 10px;font-weight: 800;" onclick="hidden2()">X</span>
            					</div><br /><br />
            					<div style="margin: 3%;width: 60%;text-align: left;">
            						<span style="font-weight: 600;">姓名：</span><span id="name"></span><br /><br />
            						<span style="font-weight: 600;">性别：</span><span id="sex"></span><br /><br />
            						<span style="font-weight: 600;">手机：</span><span id="phone"></span><br /><br />
            						<span style="font-weight: 600;">单元楼栋：</span><span id="housernum"></span><br /><br />
            						<span style="font-weight: 600;">车牌号：</span><span id="carid"></span><br /><br />
            						<span style="font-weight: 600;">身份证号：</span><span id="idcard"></span><br /><br />
            						<span style="font-weight: 600;">身份证照片：</span><br />
            						<span id="identity_img1"></span>&nbsp;<span id="identity_img2"></span><br /><br />
            						<span style="font-weight: 600;">身份证照片：</span><br />
            						<span id="photo_img"></span><br /><br />
            						<span style="font-weight: 600;">审核状态：</span><span id="state"></span><br /><br />
            						<center><button id="stateYes" onclick="StateYes(this)">审核通过</button> <button style="background:red;" id="stateNo" onclick="StateNo(this)">不通过</button></center>
            					</div>
            				</div>

            		</div>
    	</body>
    	<% } %>
    	<script type="text/javascript">
        	    function AdminOutlogin(){
        	    	window.location.href="AdminOutLogin";
        	    }
        	    function userManage(){
                    window.location.href="UserInfo";
                }
                function Community(){
                    window.location.href="CommunityInfo";
                 }
                function Room(){
                    window.location.href="RoomInfo";
                 }
                function info(){
                    window.location.href="Info";
                 }
function show(info_id,name,sex,phone,housernum,carid,idcard,identity_img1,identity_img2,photo_img,state){
				document.getElementById("stateYes").value=info_id;
				document.getElementById("stateNo").value=info_id;
				document.getElementById("name").innerHTML=name;
				document.getElementById("sex").innerHTML=sex;
				document.getElementById("phone").innerHTML=phone;
				document.getElementById("housernum").innerHTML=housernum;
				document.getElementById("carid").innerHTML=carid;
				document.getElementById("idcard").innerHTML=idcard;
				document.getElementById("identity_img1").innerHTML="<img src='"+identity_img1+"' width='55%' />";
				document.getElementById("identity_img2").innerHTML="<img src='"+identity_img2+"' width='55%' />";
				document.getElementById("photo_img").innerHTML="<img src='"+photo_img+"' width='50%' />";
				if(state ==0)
					document.getElementById("state").innerHTML="<font color='#555555'>待审核</font>";
				if(state ==1)
					document.getElementById("state").innerHTML="<font color='green'>已审核</font>";
				if(state ==2)
					document.getElementById("state").innerHTML="<font color='red'>未通过</font>"
				document.getElementById("shadow").style.display="block";
			}
			function hidden2(){
				document.getElementById("shadow").style.display="none";
			}
        	</script>
    </html>